//
//  BIDPushAnimation.m
//  EducationAssistant
//
//  Created by mal on 15/9/10.
//  Copyright (c) 2015年 cnsoft. All rights reserved.
//

#import "BIDPushAnimation.h"

@implementation BIDPushAnimation

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
    return 0.3f;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
    UIViewController *srcController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *desController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    [[transitionContext containerView] addSubview:desController.view];
    desController.view.alpha = 1.0f;
    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    desController.view.frame = CGRectMake(0, screenSize.height, screenSize.width, screenSize.height-64);
    
    [UIView animateWithDuration:[self transitionDuration:transitionContext]
                     animations:^{
                         CGRect frame = desController.view.frame;
                         frame.origin.y = 64;
                         desController.view.frame = frame;
                     }
                     completion:^(BOOL finished) {
                         [transitionContext completeTransition:YES];
                     }];
}

@end
